package com.pattern.factory.simpleFactory;

import com.pattern.factory.Hotel;
import com.pattern.factory.House;
import org.junit.Test;

/**
 * Description  简单工厂类得Demo
 *
 * @author hubiao
 * @since 2020-08-18 21:27
 */
public class SimpleFactoryTest {


    /**
     * 最初的简单工厂模式
     */
    @Test
    public void test01() {
        HouseFactory houseFactory = new HouseFactory();
        House house = houseFactory.createHouseOne( "netAbout" );
        if (house != null) {
            house.describe();
        }
    }


    /**
     * 改进第一版：简单工厂模式 + 反射
     *
     * @return
     */
    @Test
    public void test02() {
        HouseFactory houseFactory = new HouseFactory();
        House house = houseFactory.createHouseTwo( "com.pattern.factory.Hotel" );
        if (house != null) {
            house.describe();
        }
    }

    /**
     * 改进第二版：简单工厂模式 + 反射
     *
     * @return
     */
    @Test
    public void test03() {
        HouseFactory houseFactory = new HouseFactory();
        House house = houseFactory.createHouseThree( Hotel.class );
        if (house != null) {
            house.describe();
        }
    }
}
